#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author   : Moty
# @Time     : 2024/10/18 22:39
# @File     : kc16_41.py
# @Project  : CSPT
def parse_41_Balance_Update_Response(body):
    # 解析0x41 余额更新应答
    data = {
        "桩编号": f"{body[0:14]}({body[0:14]})",
        "物理卡号": f"{body[22:30]}({body[22:30]})",
        "修改结果": f"{update_result(body[30:32])}({body[30:32]})",
    }
    formatted_data = ""
    for key, value in data.items():
        formatted_data += f"{key}: {value}\n"
    return formatted_data


def update_result(result):
    return "修改成功" if result == "00" else "设备编号错误" if result == "01" else "卡号错误" if result == "02" else "未知"


__all__ = ['parse_41_Balance_Update_Response']
